package com.jf.furn.bean;

import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-11-18
 * Time:10:35
 */
@Getter
@Setter
public class Message {
    private int status;
    private String message;
    private Map<String, Object> extend;
    public static Message getSuccess() {
        return getSuccess(null);
    }
    public static Message getSuccess(String message){
        Message msg = new Message();
        msg.message = message == null ? "success" : message;
        msg.status = 200;
        return msg;
    }
    public static Message getFailed() {
        Message msg = new Message();
        msg.status = 400;
        msg.message = "failed";
        return msg;
    }
    public void addData(String key, Object value) {
        if (extend == null) {
            extend = new HashMap<>();
        }
        extend.put(key, value);
    }
}
